import { FC } from 'react';
import { Navigate } from 'react-router-dom';
import { adminRoutes, AdminRouter } from './route'
import { Frame } from './component'

import { useRecoilValue } from 'recoil';
import { userState } from './store'

import { ConfigProvider } from 'antd';
// import './App.css';

// 获取导航菜单
const menu = adminRoutes.filter(route => route.isNav === true)

const App: FC = () => {
  const lang = useRecoilValue(userState.langAtom);
  const isLogin = useRecoilValue(userState.loginAtom);
  // console.log(isLogin)

  return (
    <ConfigProvider locale={ lang }>
    {
      isLogin
      ?
      <Frame menu={menu} >
        <AdminRouter />
      </Frame>
      :
      <Navigate to={'/'} />
    }
    </ConfigProvider>
  );
}

export default App;